<?php

/*-----------------------------------------------------------------------------------*/
/*  Change theme color schemes
/*-----------------------------------------------------------------------------------*/
add_action( 'wp_enqueue_scripts', 'cv_theme_stylesheet' );
function cv_theme_stylesheet() {
	$data = cv_get_option();
	if ($data['alt_colorscheme'] != '') {			
		wp_enqueue_style( 'cv-theme-colorscheme', trailingslashit(THEME_STYLES_URI) . 'colors/' . $data['alt_colorscheme']);		
	}				
}	
	
/*-----------------------------------------------------------------------------------*/
/* Output CSS from standarized options */
/*-----------------------------------------------------------------------------------*/
add_action('wp_head', 'cv_head_css');
function cv_head_css() {
		$data = cv_get_option();

		$output = '';
		
		if ($body_color = $data['body_background'] ) {		
			$output .= "body {background:" . $body_color .";}\n";			
		}
		
		if ($header_color = $data['header_background'] ) {
			$output .= "#header {background:" . $header_color .";}\n";
		}
		
		if ($footer_color = $data['footer_background'] ) {
			$output .= "#footer {background:" . $footer_color .";}\n";
		}		
	
		//sample typography
/*		if ($typography = $data['body_font'] ) {
			$output .= "body {\n     font-face:" . of_font_stack($typography['face']) . "; \n";
			$output .= "     font-size:" . $typography['size'] . "; \n";
			$output .= "     font-style:".$typography['style'] . "; \n";
			$output .= "     color: ".$typography['color'] . "; \n";
			$output .= "}\n";
		}
*/		
		$custom_css = $data['custom_css'];
		
		if ($custom_css <> '') {
			$output .= $custom_css . "\n";
		}		
		// Output styles
		if ($output <> '') {
			$output = "<!-- Custom Styling -->\n<style type=\"text/css\">\n" . $output . "</style>\n";
			echo $output;
		}
		
	
}

/*-----------------------------------------------------------------------------------*/
/* Add Favicon
/*-----------------------------------------------------------------------------------*/
add_action('wp_head', 'cv_theme_favicon');
function cv_theme_favicon() {
		$data = cv_get_option();
		if ($data['custom_favicon'] != '') {
	        echo '<link rel="shortcut icon" href="'.  $data['custom_favicon']  .'"/>'."\n";
	    }
		else { ?>
			<link rel="shortcut icon" href="<?php echo CV_THEME_URI ?>/images/favicon.ico" />
<?php }
}

/*-----------------------------------------------------------------------------------*/
/* Show analytics code in footer */
/*-----------------------------------------------------------------------------------*/
add_action('wp_footer','cv_analytics_code');
function cv_analytics_code() {
	$data = cv_get_option();
	$output = $data['analytics_code'];
	if ( $output <> "" ) 
		echo stripslashes($output) . "\n";
}

?>